import request from "@/utils/request";
import {PATH_SYS_DNF} from "@/utils/constant";
import {Recharge} from "@/api/sys/dnf/recharge/types";

const baseUrl = PATH_SYS_DNF + '/recharge/'

/**
 * 查询充值列表 - 带分页
 * @param data
 */
export function getRechargeListApi(data: PageQuery<Recharge>): PromisePageListType<Recharge> {
    return request.post(baseUrl + 'list', data)
}

/**
 * 通过充值id获取充值信息
 * @param id
 */
export function getRechargeByIdApi(id: number): Promise<Recharge> {
    return request.get(baseUrl + id)
}

/**
 * 修改充值
 * @param id
 * @param data
 */
export function editRechargeApi(id: number, data: Recharge): Promise<any> {
    return request.patch(baseUrl + id, data)

}

/**
 * 添加充值
 * @param data
 */
export function addRechargeApi(data: Recharge): Promise<any> {
    return request.post(baseUrl, data)
}

/**
 * 删除充值
 * @param id
 */
export function deleteRechargeApi(id: number): Promise<any> {
    return request.delete(baseUrl + id)
}

/**
 * 购买
 * @param id
 */
export function buyRechargeApi(id: number): Promise<any> {
    return request.post(baseUrl + 'buy/' + id)
}